package com.talkweb.osmharmony.util;


import com.talkweb.osmharmony.config.Configuration;
import ohos.location.Location;
import ohos.location.Locator;

public class LocationUtils {

    /**
     * This is a utility class with only static members.
     */
    private LocationUtils() {
    }

    /**
     * Get the most recent location from the GPS or Network provider.
     *
     * @return return the most recent location, or null if there's no known location
     */
    public static Location getLastKnownLocation(final Locator pLocationManager) {
        if (pLocationManager == null) {
            return null;
        }
//        final Location gpsLocation = getLastKnownLocation(pLocationManager, LocationManager.GPS_PROVIDER);
//        final Location networkLocation = getLastKnownLocation(pLocationManager, LocationManager.NETWORK_PROVIDER);
//        if (gpsLocation == null) {
//            return networkLocation;
//        } else if (networkLocation == null) {
//            return gpsLocation;
//        } else {
//            // both are non-null - use the most recent
//            if (networkLocation.getTimeStamp() > gpsLocation.getTimeStamp() + Configuration.getInstance().getGpsWaitTime()) {
//                return networkLocation;
//            } else {
//                return gpsLocation;
//            }
//        }
        return pLocationManager.getCachedLocation();
    }
}
